//导入请求工具request.js，就相当于可以直接使用请求工具里的axios了
import request from '@/utils/request.js'

//文章分类列表查询
export const articleCategoryListService = () => {
    return request.get('/category')
}

//文章分类添加
export const articleCategoryAddService = (categoryData) => {
    return request.post('/category', categoryData)
}

//文章分类修改
export const articleCategoryUpdateService = (categoryData) => {
    return request.put('/category', categoryData)
}

//文章分类删除
export const articleCategoryDeleteService = (id) => {
    return request.delete('/category?id=' + id)
}

//文章列表查询
export const articleListService = (params) => {
    /*  request.js的拦截器本身是异步的
        而且在.vue组件中，调用该方法时，前边加上了await
        所以这里return时，不用写await和async
    */
    return request.get('/article', { params: params })
}

//文章添加
export const articleAddService = (articleData) => {
    return request.post('/article', articleData);
}

//文章修改
export const articleUpdateService = (articleData) => {
    return request.put('/article', articleData);
}

//删除文章
export const articleManageDeleteService = (id) => {
    return request.delete('/article?id=' + id)
}